package demo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class W8_DouDiZhu {
	public static void main(String[] args) {

		// 准备牌
		ArrayList<Integer> poker = new ArrayList<Integer>();
		ArrayList<String> poker1 = new ArrayList<String>();
		ArrayList<String> poker2 = new ArrayList<String>();
		ArrayList<String> poker3 = new ArrayList<String>();
		Map<Integer, String> map = new HashMap();
		// 定义两个数组
		String[] colors = { "♥", "♣","♦" ,"♠"  };
		String[] numbers = { "2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3" };
		poker.add(0);
		poker.add(1);
		// 组装52张牌
		Integer index = 2;
		map.put(0, "大王");
		map.put(1, "小王");
		for (String number : numbers) {
			for (String color : colors) {
				poker.add(index);
				map.put(index, color + number);
				index++;
			}
		}

		// 洗牌
		Collections.shuffle(poker);

		Player playe1 = new Player("老王");
		Player playe2 = new Player("老李");
		Player playe3 = new Player("老刘");
		// 摸牌
		for (int i = 0; i < poker.size(); i++) {
			// 每一张牌
			Integer p = poker.get(i);
			if (i <= 51) {
				if (i % 3 == 0) {
					playe1.getList().add(p);
				} else if (i % 3 == 1) {
					playe2.getList().add(p);
				} else {
					playe3.getList().add(p);
				}
			}
		}
		Collections.sort(playe1.getList());
		Collections.sort(playe2.getList());
		Collections.sort(playe3.getList());
		// 看牌
		for (int i : playe1.getList()) {
			poker1.add(map.get(i));
		}
		System.out.println(poker1);

		for (int i : playe2.getList()) {
			poker2.add(map.get(i));
		}
		System.out.println(poker2);

		for (int i : playe3.getList()) {
			poker3.add(map.get(i));
		}
		System.out.println(poker3);
	}
}